
import React, { useState, useEffect } from 'react'

export default function App() {
  
  const [ count, setCount ] = useState(0)
  const [ msg, setMsg ] = useState("")

  // useEffect 依赖项可以同时写多个
  useEffect(() => {
    console.log("我被执行了");
  }, [count,msg]) // [依赖项，依赖项2，....] 多个依赖项，表示同时监听多个状态的变化


  return (
    <div>

      count -- {count}
      <hr />
      <button onClick={() => setCount(count + 1)}>点击改变count</button>
      <hr />
      msg -- {msg}
      <hr />
      <button onClick={() => setMsg(msg + "~")}>点击改变count</button>
    </div>
  )
}